<%-- 
    Document   : checkMessage
    Created on : Mar 6, 2014, 11:02:53 AM
    Author     : Jordan,Theodoro
--%>

<%@page contentType="text/html" pageEncoding="UTF-8" errorPage="error.jsp"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<c:if test="${sessionScope.username == NULL}">
    <c:redirect url="http://webtek.org/Bonix/php/public/index.php"/>
</c:if>
<c:set scope="request" var="title" value="Message"/>


<sql:setDataSource user="root" password="" driver="com.mysql.jdbc.Driver"
                   url="jdbc:mysql://localhost/bonix"/>


<sql:query var="getMessage">
    Select sender,msg,sent_date from messages 
    where entry_id = ?;
    <sql:param value="${param.entry_id}"/>
</sql:query>


<sql:update sql="UPDATE `bonix`.`messages` SET `status`='read' WHERE `entry_id`=?">
    <sql:param value = "${param.entry_id}"/>
</sql:update>

<!DOCTYPE html>
<html>
    <jsp:include page="head.jsp"/>
    <body>
        <jsp:include page="banner.jsp"/>

        <div class="row">
            <div class="container_header">
                <div class="content row">

                    <div class="containerService">

                        <div class="panel panel-info">

                            <div class="panel-heading">
                                <ul class="navClient navClient-pills">

                                    <c:url var="messagesURL" value="messages.jsp" />
                                    <li><a href="${messagesURL}"> Message Inbox </a></li>

                                    <c:url var="composeURL" value="compose.jsp" />
                                    <li><a href="${composeURL}"> Compose Message </a></li>

                                    <c:url var="sentItemsURL" value="sentItems.jsp" />
                                    <li><a href="${sentItemsURL}"> Sent Items </a></li>
                                </ul>
                            </div>

                            <div class="panel-body">
                                <br><hr><br>
                                <c:forEach var="message" items="${getMessage.rows}">
                                    <div class="messages">
                                        <input type="text" name="first" value="${message.sender}" class="form-control" readonly>
                                        <br>
                                        <label>Message:</label>
                                        <textarea class="form-control" name="message" rows="10" cols="50" readonly>${message.msg}</textarea>
                                        <br>
                                        <c:url var="composereplyURL" value="compose.jsp">
                                            <c:param name="messageSender" value="${message.sender}"></c:param>
                                        </c:url>
                                    </div>
                                </c:forEach>

                                <a href="${composereplyURL}" class="btn btn-primary" role="button">REPLY</a>
                                <a href="delete.jsp?entry_id=${param.entry_id}" class="btn btn-primary" role="button">DELETE</a>

                            </div><!-- END panel-body -->

                        </div><!-- END panel-info -->
                    </div><!-- END containerService -->

                </div><!-- END CONTENT CONTENT ROW -->
            </div><!-- END CONTAINER -->
        </div><!-- END ROW -->

        <jsp:include page="footer.jsp"/>

    </body>
</html>
